package com.nzy.file;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @author jukg
 * @date 2023/05/15 17:04
 * @description
 */
public class FileRead {

    public static void main1(String[] args) throws IOException {
        String siteId = "4601000099";
        AtomicReference<Long> successAmount  = new AtomicReference<>(0L);
        AtomicReference<Long> failedAmount  = new AtomicReference<>(0L);
        AtomicInteger count = new AtomicInteger();
        Path path = Paths.get("G:\\Wechat\\WeChat Files\\jukaigong\\FileStorage\\File\\2023-05\\20230511_460000_computer-tickets_10005_13.txt");
        Files.lines(path).forEach(item -> {
           String[] ss = item.split("\\|");
           if(siteId.equals(ss[2])){
                if("2".equals(ss[1])){
                    successAmount.updateAndGet(v -> v + Long.valueOf(ss[3]));
                }else{
                    failedAmount.updateAndGet(v -> v + Long.valueOf(ss[3]));
                }
               count.getAndIncrement();
           }
        });
        System.out.println("账户:" + siteId + "，对账订单：" + count.get() + "条");
        System.out.println("成功：" + successAmount.get() + ",失败：" + failedAmount.get());
    }

    public static void main(String[] args) throws IOException {
        File file = new File("D://tmp//t1//t2//t3");
        if(!file.exists()){
            file.mkdirs();
        }
        File file2 = new File("D://tmp//t1//t2//t3//test.txt");
        file2.createNewFile();
    }
}
